<?php
	/**
	 * Серверная поддержка автокомплита.
	 * 
	 * @author Костин Алексей Васильевич aka Volt(220)
	 * @copyright Copyright (c) 2010, Костин Алексей Васильевич
	 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public License
	 * @version 1.0
	 * @package HomeMoney
	 */

	/**
	 * Подключение настроек. 
	 */
	require_once("../ini.php");

	$DBCon=SQLDBFactory::getDB();


	if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
		if($_GET['q']){
			$newItem=$DBCon->escape($_GET['q']);
			$tab=$DBCon->escapeKeys($_GET['tab']);
			$field=$DBCon->escapeKeys($_GET['field']);
			$DBCon->select("select distinct $field from $tab where $field like '$newItem%'");
			while($mas=$DBCon->fetchRow()){
				echo $mas[0],PHP_EOL;
			}  	
  	}
  	exit();
}/*
?>
<form method="post">
<p><input name="q" type="text" size="100" /></p>
<p><input type="submit" /></p>
</form>
<?php 
if($_POST['q']){
	echo $_POST['q'], "<br />";
	$newItem=$DBCon->escape($_POST['q']);
	$sql="select item from goods where item like '$newItem%'";
	echo $sql;
	$res=$DBCon->select("select item from goods where item like '$newItem%'");
	while($mas=mysql_fetch_row($res)){
		echo $mas[0],"<br />";
	}  	
  }



*/
?>